package com.csweimei.rentmanagementtreasure.tenant.ui.act.house;

import static com.csweimei.rentmanagementtreasure.base.AppConfig.BUNDLE_KEY;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.chad.library.BR;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.adapter.HouseCxAdapter;
import com.csweimei.rentmanagementtreasure.databinding.ActivityAddMoreBinding;
import com.csweimei.rentmanagementtreasure.http.postBean.PostHouseInfoBean;
import com.csweimei.rentmanagementtreasure.tenant.viewModel.AddMoreVM;

import java.util.Arrays;

import me.goldze.mvvmhabit.base.BaseActivity;

public class AddMoreActivity extends BaseActivity<ActivityAddMoreBinding, AddMoreVM> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_add_more;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    private PostHouseInfoBean postHouseInfoBean;

    @Override
    public void initParam() {
        super.initParam();
        postHouseInfoBean = (PostHouseInfoBean) getIntent().getSerializableExtra(BUNDLE_KEY);
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(this);
        viewModel.entity.set(postHouseInfoBean);
        setCXAdapter();

    }

    private void setCXAdapter() {
        HouseCxAdapter cxAdapter = new HouseCxAdapter();
        cxAdapter.addChildClickViewIds(R.id.name);
        binding.recyclerCx.setAdapter(cxAdapter);
        cxAdapter.setOnItemChildClickListener((adapter, view, position) -> {
            cxAdapter.setSel(position);
            viewModel.toward.set(cxAdapter.getData().get(position));
        });

        cxAdapter.setList(Arrays.asList(getResources().getStringArray(R.array.cxList)));

    }


}